<?php
namespace app\index\controller;
use \think\Db;
use \think\Request;
use \think\Controller;
header("Content-Type: text/html; charset=UTF-8");

class discuss
{
    
    public function index()
    {
        //获取所有帖子信息
        $request = Request::instance();
        // $res = Db::name('article')->field('id,uid,image,content,lable_name,time,praise')->select();
        // //var_dump($res);die();
        // $userinfo = Db::name('user')->field('username,userpic')->where('uid','eq',$userid)->select();
        $data = Db::name('article')->alias('a')->join('user u','u.uid = a.uid')->field('u.username,u.userpic,a.image,a.title,a.content,a.lable_name,.')->select();
        
        //var_dump($userinfo);exit;
        
        var_dump($data);
    }

    public function articleHot(){
    	//获取所有为问答且属于热门的帖子
    	$request = Request::instance();
    	$res = Db::name('article')->where('content','>',100)->where('status','eq',1)->where('is_hot','eq',1)->select();

    	return $res;
    }

    //未答问题
    public function noAnswer(){
    	//获取所有没有回复的帖子
    	$request = Request::instance();
    	$res = Db::name('article')->where('content','eq',0)->select();

    	return $res;

    }

}
